Test Series - java script

Test Number 2/92

Q: 
A. 
B. 
C. 
D. 
Solution: 
Q: What will be the output of the following JavaScript code?

var txt1 = "good"; var txt2 = "day"; document.getElementById("demo").innerHTML = txt1 + txt2;
A. good day
B. goodday
C. error
D. undefined
Solution: The + operator acts as a concatenation operator when used with string. The new string does not have any space between the two added string.
Q: What will be the output of the following JavaScript code?

A. 0
B. 1
C. 2
D. 5
Solution: The % operator returns the remainder between the two numbers. It is used many times with if condition to check whether the number is divisible or not.
Q:  What will be the output of the following JavaScript code?

A. 5
B. 10
C. 50
D. Error
Solution: The *= operator is a shorthand expression for multiplication of a particular number. It is a combination of two operators * and = .
Q: What will be the output of the following JavaScript code?

A. onetwo
B. one two
C. error
D. undefined
Solution: The += operator acts in the same way as the concatenation operator in the string. There is no space added when two string are added together with += operator.
Q: What will be the output of the following JavaScript code?

A. integer
B. number
C. string
D. error
Solution: The typeof operator returns the type of the argument passed to it. The typeof operator returns number for an integer and string for a character array.
Q: JavaScript Code can be called by using ___________
A. RMI
B. Triggering Event
C. Preprocessor
D. Function/Method
Solution: JavaScript code can be called by making a function call to the element on which JavaScript has to be run. There are many other methods like onclick, onload, and onsubmit etc.
Q: The type of a variable that is volatile is _______________
A. Volatile variable
B. Mutable variable
C. Immutable variable
D. Dynamic variable
Solution: The variables whose values can be changed are called mutable variable types. In JavaScript, only objects and arrays are mutable, not primitive values.
Q: A hexadecimal literal begins with __________
A. 00
B. 0x
C. 0X
D. Both 0x and 0X
Solution: Generally, X or x denotes hexadecimal values. So, any integer literal that begins with 0X or 0x denotes a hexadecimal number.
Q: The generalised syntax for a real number representation is __________
A. [digits][.digits][(E|e)[(+|-)]digits]
B. [digits][+digits][(E|e)[(+|-)]digits]
C. [digits][(E|e)[(+|-)]digits]
D. [.digits][digits][(E|e)[(+|-)]digits]
Solution: Floating-point literals may also be represented using exponential notation: a real number followed by the letter e (or E), followed by an optional plus or minus sign, followed by an integer exponent. This notation represents the real number multiplied by 10 to the power of the exponent.
Q: JavaScript _________ when there is an indefinite or an infinite value during an arithmetic computation.
A. Prints an exception error
B. Prints an overflow error
C. Displays “Infinity”
D. Prints the value as such
Solution: When the result of a numeric operation is larger than the largest representable number (overflow), JavaScript prints the value as Infinity. Similarly, when a negative value becomes larger than the largest representable negative number, the result is negative infinity. The infinite values behave as you would expect: adding, subtracting, multiplying, or dividing them by anything results in an infinite value (possibly with the sign reversed).

You Have Score    /11